package com.zwf.mapper;

import com.github.pagehelper.Page;
import com.zwf.annotation.AutoFill;
import com.zwf.dto.SetmealDTO;
import com.zwf.dto.SetmealPageQueryDTO;
import com.zwf.entity.Setmeal;
import com.zwf.enumeration.OperationType;
import com.zwf.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author zwf
 * @date 2024/2/1 15:12
 * @PackageName:com.zwf.mapper
 * @ClassName:SetmealMapper
 * @Description: TODO
 * @Version: 1.0
 */
@Mapper
public interface SetmealMapper {
    /**
     * 根据分类id查询关联的套餐数
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id=#{id}")
     int count(Long id) ;

    /**
     * 动态条件查询套餐
     * @param setmeal
     * @return
     */
    List<Setmeal> list(Setmeal setmeal);

    /**
     * 套餐分页查询
     * @param setmealPageQueryDTO
     * @return
     */
    Page<Setmeal> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);


    /**
     * 根據id查詢套餐
     * @param id
     * @return
     */
    @Select("select * from setmeal where id=#{id}")
    Setmeal queryById(Long id);

    /**
     * 新增套餐
     * @param setmeal
     */
    @AutoFill(value = OperationType.INSERT)
    void add(Setmeal setmeal);

    /**
     * 批量删除套餐
     * @param ids
     */
    void delete(List<Long> ids);

    /**
     * 更新套餐
     * @param setmeal
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 根据状态查询套餐数
     * @param status
     * @return
     */
    @Select("select count(*) from setmeal where status=#{status}")
    Integer countByStatus(Integer status);
}
